/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package o2uz;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author tomcat
 */
@Entity
@Table(name = "user")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findByIdUser", query = "SELECT u FROM User u WHERE u.idUser = :idUser"),
    @NamedQuery(name = "User.findByEMail", query = "SELECT u FROM User u WHERE u.eMail = :eMail"),
    @NamedQuery(name = "User.findByName", query = "SELECT u FROM User u WHERE u.name = :name"),
    @NamedQuery(name = "User.findBySurname", query = "SELECT u FROM User u WHERE u.surname = :surname"),
    @NamedQuery(name = "User.findByIndexNumber", query = "SELECT u FROM User u WHERE u.indexNumber = :indexNumber"),
    @NamedQuery(name = "User.findByDescription", query = "SELECT u FROM User u WHERE u.description = :description"),
    @NamedQuery(name = "User.findByTitle", query = "SELECT u FROM User u WHERE u.title = :title"),
    @NamedQuery(name = "User.findByRating", query = "SELECT u FROM User u WHERE u.rating = :rating"),
    @NamedQuery(name = "User.findByActive", query = "SELECT u FROM User u WHERE u.active = :active"),
    @NamedQuery(name = "User.findByAccountCreateYear", query = "SELECT u FROM User u WHERE u.accountCreateYear = :accountCreateYear")})
public class User implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_user")
    private Integer idUser;
    @Basic(optional = false)
    @Column(name = "e-mail")
    private String eMail;
    @Column(name = "name")
    private String name;
    @Column(name = "surname")
    private String surname;
    @Column(name = "index_number")
    private Integer indexNumber;
    @Column(name = "description")
    private String description;
    @Column(name = "title")
    private String title;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "rating")
    private BigDecimal rating;
    @Column(name = "active")
    private Boolean active;
    @Column(name = "account_create_year")
    private Integer accountCreateYear;
    @JoinColumn(name = "fk_user_role", referencedColumnName = "id_user_role")
    @ManyToOne(optional = false)
    private UserRole fkUserRole;
    @JoinColumn(name = "fk_institute", referencedColumnName = "id_institute")
    @ManyToOne(optional = false)
    private Institute fkInstitute;
    @JoinColumn(name = "fk_group", referencedColumnName = "id_group")
    @ManyToOne(optional = false)
    private Group1 fkGroup;

    public User() {
    }

    public User(Integer idUser) {
        this.idUser = idUser;
    }

    public User(Integer idUser, String eMail) {
        this.idUser = idUser;
        this.eMail = eMail;
    }

    public Integer getIdUser() {
        return idUser;
    }

    public void setIdUser(Integer idUser) {
        this.idUser = idUser;
    }

    public String getEMail() {
        return eMail;
    }

    public void setEMail(String eMail) {
        this.eMail = eMail;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public Integer getIndexNumber() {
        return indexNumber;
    }

    public void setIndexNumber(Integer indexNumber) {
        this.indexNumber = indexNumber;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public BigDecimal getRating() {
        return rating;
    }

    public void setRating(BigDecimal rating) {
        this.rating = rating;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public Integer getAccountCreateYear() {
        return accountCreateYear;
    }

    public void setAccountCreateYear(Integer accountCreateYear) {
        this.accountCreateYear = accountCreateYear;
    }

    public UserRole getFkUserRole() {
        return fkUserRole;
    }

    public void setFkUserRole(UserRole fkUserRole) {
        this.fkUserRole = fkUserRole;
    }

    public Institute getFkInstitute() {
        return fkInstitute;
    }

    public void setFkInstitute(Institute fkInstitute) {
        this.fkInstitute = fkInstitute;
    }

    public Group1 getFkGroup() {
        return fkGroup;
    }

    public void setFkGroup(Group1 fkGroup) {
        this.fkGroup = fkGroup;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idUser != null ? idUser.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.idUser == null && other.idUser != null) || (this.idUser != null && !this.idUser.equals(other.idUser))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "o2uz.User[ idUser=" + idUser + " ]";
    }
    
}
